<template>
  <div>
    <div class="videoes">
      <div class="video-top"></div>
      <!-- 内容 -->
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="getHomeVideosFun()"
        style="padding-bottom: 60px"
      >
        <!-- 内容 -->
        <div
          class="video-content"
          v-for="(item, index) in videoresult"
          :key="index"
        >
          <div class="content-header">
            <div class="header-img">
              <img :src="item.a.p" alt="" />
            </div>
            <div class="header-user">
              <div class="username">
                <h3>花样厨娘-钱包RitaQ</h3>
                <span>LV.{{ item.a.lvl }}</span>
              </div>
            </div>
            <div class="header-follow">
              <span>关注</span>
            </div>
          </div>
          <div class="content-img" @click="jump(item.id)">
            <img :src="item.img" alt="" />
            <div class="play">
              <i class="iconfont icon-24gf-play"></i>
            </div>
          </div>
          <div class="content-footer">
            <div class="footer-top">
              <ul class="top-left">
                <!-- <li class="imgone">
                  <img
                    src="http://tx1.douguo.net/upload/photo/8/0/6/70_u4988624853610329203208.jpg"
                    alt=""
                  />
                </li>
                <li class="imgtwo">
                  <img
                    src="http://tx1.douguo.net/upload/photo/8/0/6/70_u4988624853610329203208.jpg"
                    alt=""
                  />
                </li>
                <li class="imgthree">
                  <img
                    src="http://tx1.douguo.net/upload/photo/3/0/3/70_u4988524853570329203208.jpg"
                    alt=""
                  />
                </li>
                <li class="imgfour">
                  <img
                    src="http://tx1.douguo.net/upload/photo/a/5/4/70_u4988924853980329203210.jpg"
                    alt=""
                  />
                </li> -->
                <li v-for="(k, i) in item.collect_users" :key="i">
                  <img :src="k.p" alt="" />
                </li>
              </ul>
              <div class="top-center">
                <span>{{ item.collect_count_text }}</span>
              </div>
              <div class="top-right">
                <i class="iconfont icon-shoucang"></i>
              </div>
            </div>
            <div class="footer-center">
              <span> {{ item.n }} </span>
            </div>
          </div>
        </div>
      </van-list>
    </div>
  </div>
</template>

<script>
import { getHomeVideos } from "../../api/home/video";
export default {
  name: "videoes",
  data() {
    return {
      loading: false,
      finished: false,
      refreshing: false,
      videoresult: [],
      numA: 0,
      numB: 10,
    };
  },
  methods: {
    //获取视频数据
    getHomeVideosFun() {
      getHomeVideos({ offset: 20, limit: 40 }).then((data) => {
        // console.log("视频数据", data.result.list);
        let ids = data.result.list.slice(this.numA, this.numB);
        let video = ids;
        // this.videoresult = video;
        video.forEach((value) => {
          if (value.type == 1) {
            this.videoresult.push(value.r);
          }
        });
        // console.log("数据r", this.videoresult);

        // 加载状态结束
        this.loading = false;

        // 数据全部加载完成
        if (ids.length > 0) {
          this.numA += 10;
          this.numB += 10;
        } else if (ids.length <= 0) {
          this.finished = true;
        }
      });
    },
    //跳转到菜谱详情页面
    jump(id) {
      this.id = id;
      this.$router.push({
        name: "details",
        params: {
          id: this.id,
        },
      });
    },
  },
};
</script>

<style lang="less">
.videoes {
  .video-top {
    width: 100%;
    height: 105px;
  }
  .video-content {
    padding-bottom: 10px;
    .content-header {
      margin: 15px 10px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .header-img {
        width: 35px;
        height: 35px;
        img {
          width: 100%;
          height: 100%;
          border-radius: 50%;
        }
      }
      .header-user {
        width: 61%;
        margin-left: 10px;
        .username {
          font-weight: bold;
          display: flex;
          align-items: center;
          h3 {
            font-size: 14px;
            font-weight: bold;
            color: #000;
          }
          span {
            font-size: 10px;
            color: #c48f23;
            margin-left: 10px;
          }
        }
        .user-information {
          span {
            font-size: 12px;
            color: #868686;
          }
        }
      }
      .header-follow {
        margin-right: 5px;
        span {
          width: 70px;
          height: 30px;
          font-size: 12px;
          font-weight: bold;
          color: #000;
          background-color: #fec538;
          border: 1px solid #fec538;
          border-radius: 50px;
          padding: 5px 20px;
        }
      }
    }
    .content-img {
      width: 100%;
      background-color: #e0e0e0;
      margin-bottom: 12px;
      position: relative;
      img {
        width: 100%;
        height: 100%;
      }
      .play {
        position: absolute;
        right: 8px;
        bottom: 10px;
        width: 30px;
        height: 30px;
        border-radius: 50%;
        background-color: #34231c;
        opacity: 0.7;
        i {
          position: absolute;
          right: 7px;
          bottom: 8px;
          font-size: 13px;
          color: #fff;
        }
      }
    }
    .content-footer {
      margin: 15px 12px 0;
      .footer-top {
        margin: 5px 0px;
        display: flex;
        .top-left {
          width: 20%;
          height: 25px;
          position: relative;
          li:nth-child(1) {
            position: absolute;
            top: 0;
            left: 0;
            width: 22px;
            height: 22px;
            border-radius: 50%;
            background-color: #e6e6e6;
            img {
              width: 100%;
              height: 100%;
              border-radius: 50%;
            }
          }
          li:nth-child(2) {
            position: absolute;
            top: 0;
            left: 16px;
            width: 22px;
            height: 22px;
            border-radius: 50%;
            background-color: #e6e6e6;
            img {
              width: 100%;
              height: 100%;
              border-radius: 50%;
            }
          }
          li:nth-child(3) {
            position: absolute;
            top: 0;
            left: 32px;
            width: 22px;
            height: 22px;
            border-radius: 50%;
            background-color: #e6e6e6;
            img {
              width: 100%;
              height: 100%;
              border-radius: 50%;
            }
          }
          li:nth-child(4) {
            position: absolute;
            top: 0;
            left: 48px;
            width: 22px;
            height: 22px;
            border-radius: 50%;
            background-color: #e6e6e6;
            img {
              width: 100%;
              height: 100%;
              border-radius: 50%;
            }
          }
        }
        .top-center {
          width: 38.6%;
          height: 25px;
          line-height: 25px;
          margin-left: 10px;
          span {
            font-size: 14px;
            // font-weight: bold;
            color: #000;
          }
        }
        .top-right {
          width: 32%;
          height: 25px;
          line-height: 25px;
          margin-left: 15px;
          display: flex;
          justify-content: flex-end;
          i {
            font-size: 25px;
          }
        }
      }
      .footer-center {
        width: 93%;
        // height: auto;
        margin-top: 10px;
        span {
          width: 335px;
          line-height: 25px;
          display: block;
          font-size: 14px;
          font-weight: bold;
          color: #000;
          word-wrap: break-word;
        }
      }
    }
  }
}
</style>